using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using SocketTool.ViewModels.ControlViewModel;

namespace SocketTool.Controls
{
    public partial class ReqMessageParamControl : UserControl
    {
        public ReqMessageParamControl()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }

        static public ReqMessageParamViewModel GetVMContext(ContentControl control,
            string controlName)
        {
            var paramControl = control.FindControl<ReqMessageParamControl>(controlName);
            if (paramControl == null)
                return null;

            return paramControl.DataContext as ReqMessageParamViewModel;
        }
    }
}